package com.solo;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet(name = "SecondServlet", value = "/SecondServlet")
public class SecondServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        response.setContentType("text/html;charset=UTF-8");
        request.setCharacterEncoding("UTF-8"); // 如果接收的请求数据是中文，也要设置请求编码
        response.setCharacterEncoding("UTF-8"); // 设置响应编码
        // response.setContentType("text/html;charset=UTF-8");
        PrintWriter out = response.getWriter();

        Student student = (Student) request.getAttribute("student");
        System.out.println("xues="+student.getStudentName());

        out.println("<html><body>");
        out.println("<h2>学号: " + student.getStudentId() + "</h2>");
        out.println("<h2>姓名: " + student.getStudentName() + "</h2>");
        out.println("<a href='input.jsp'>返回登录页面</a>");
        out.println("</body></html>");
    }
}